package com.mdd.front.controller.car;

import com.mdd.common.aop.NotLogin;
import com.mdd.common.aop.NotPower;
import com.mdd.common.core.AjaxResult;
import com.mdd.common.core.PageResult;
import com.mdd.common.validator.annotation.IDMust;
import com.mdd.front.service.product.IProductSpuFrontService;
import com.mdd.front.validate.car.CarSpuSearchValidate;
import com.mdd.front.vo.car.CarSpuDetailVo;
import com.mdd.front.vo.car.CarSpuListVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 商品信息
 * {@code @Description}
 * {@code @Author} 幻速
 * {@code @Date} 2023/11/1 18:10
 **/
@RestController
@RequestMapping("api/front/car/spu")
@Api(tags = "零售商品/采购")
public class CarSpuController {
    @Resource
    IProductSpuFrontService iProductFrontService;

    @NotLogin
    @ApiOperation(value = "初始化字典数据")
    @GetMapping("/initCarProductData")
    public AjaxResult init() {
        return AjaxResult.success(iProductFrontService.initCarProductData());
    }
    //店铺商品列表(零售/采购)
    @NotLogin
    @ApiOperation(value = "商品列表")
    @GetMapping("/list")
    public AjaxResult<PageResult<CarSpuListVo>> list(@Validated CarSpuSearchValidate carSpuSearchValidate) {
        return AjaxResult.success(iProductFrontService.page(carSpuSearchValidate));
    }
    //商品详情
    @NotLogin
    @GetMapping("/detail")
    @ApiOperation(value = "商品详情")
    public AjaxResult<CarSpuDetailVo> carSpuDetail(@Validated @IDMust() @RequestParam("id") Long id) {
        return AjaxResult.success(iProductFrontService.carSpuDetail(id));
    }


}
